﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Enter.Common;
using Enter.Config;
using Enter.Entity;
using Enter.BizLogic;

namespace Enter.Web.SystemAdmin.GoodClass
{
    public partial class importBrank : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            //  for (int p = 1; p < 13; p++)
            //{


            //    string pacode = GetCode("", p);

          string[] files=  FileHelper.File_List("G:\\项目\\网上商城\\品牌\\");
          int code = 1;
          foreach (string file in files)
            {
                string content = FileHelper.readFile(file, "GB2312");
                string filename = file.Substring(file.LastIndexOf("\\") + 1, file.LastIndexOf(".") - file.LastIndexOf("\\")-1);
                string[] str1 = content.Replace("\r\n", "").Replace("\t", "").Trim('、').Split('、');
                for (int i = 0; i<str1.Length; i++)
                {
                    save(code.ToString(), str1[i], filename.Substring(0, 2), filename);
                         code++;
                }
            }
           
        }
        private void save(string code, string name, string ParentID, string ParentID1)
        {
            T109_GoodBrandEntity model = new T109_GoodBrandEntity();
            T109_GoodBrandBLLSub bll = new T109_GoodBrandBLLSub();

            model.BNO = code;
            model.BName = name.Trim().Replace("\\","/");
            model.Weight = 0;
            model.GoodParentClassID = ParentID;
            model.GoodClassID = ParentID1;
            model.Status = EnumStatus.Valid;

            bll.Save(model);
        }
    }
}